<template>
  <div id="jindoulist" v-cloak> 


      <div class="demo" :style="{  height: dtheight + 'px' }">
            <!-- <div class="mytitle">
                <div class="mytitle_item">果种价值区间设置</div>
            </div> -->
              <div style="width:100%;"> 
                <el-form ref="form" :model="datalist" label-width="100px" style="width:50%;">

                    <el-form-item  v-for="(item,index) in valuedata" :key="index" :label="item.title">
                        <el-col :span="11">
                          <el-input v-model.number="item.min_price" placeholder="开始价值" @blur="proving1($event)"></el-input>
                        </el-col>
                        <el-col class="line" :span="2" style="text-align: center;">-</el-col>
                        <el-col :span="11">
                           <el-input v-model.number="item.max_price" placeholder="结束价值" @blur="proving1($event)"></el-input>
                        </el-col>
                    </el-form-item>    
                     
                     

                      <div style="text-align: center;width:100%;">
                          <el-button  type="primary" style="width:50%;" @click="sz_but_qr1">确认</el-button>
                       </div>
                   
                </el-form>
                
                
             </div>
    </div> 


    <el-dialog title="用户验证" :visible.sync="user_test.user_mtk"  width="400px" >
          <el-form ref="form" :model="user_test"  label-width="100px" style="width:100%;">
                <el-form-item label="" label-width="0px">
                    <el-input v-model="user_test.password" placeholder="二级密码" ></el-input>
                </el-form-item>
                <el-form-item label="" label-width="0px" >
                    <div style="display:flex;">
                        <el-input v-model="user_test.phone" placeholder="手机验证码" style="flex:1;"></el-input>
                        <el-button class="code_but1 custom_color_button" type="primary"  @click="getCode_yz()" :disabled="user_test.disabled" style="margin-left:10px;">
                          {{ user_test.codeText }}
                        </el-button>
                    </div>
                </el-form-item>
                <div style="text-align: center;width:50%;margin:auto;margin-top:20px;">
                  <el-button type="primary" class="custom_color_button" style="width:100%;" @click="user_mtk_but">确认</el-button>
                </div>
         </el-form>
   </el-dialog> 



   </div>
</template>

<script>

export default {
   name: 'jindoulist',
   props:{
      valuedata:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
        istrue:true,
        datalist:{
            
        },
        user_test:{  //用户判定
          user_mtk:false, //用户判定模态狂
          codeText:'获取验证码', //获取验证码字
          totalTime:60,  //获取验证码秒
          disabled:false, //禁用获取验证码
          password:'', //二级密码
          phone:'',  //验证码
        },
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 210
      
  },
  mounted (){
     
  },
  methods: {
    sz_but_qr1(){
       this.user_test.user_mtk = true
    },
    user_mtk_but(){

        this.getCode_yz_qr().then(res => {
            console.log(res)
            if(res == 1){
                this.sz_but_qr()
            }
        })
  
    },
   
   sz_but_qr(){
         
       this.pd_fun()
       if(this.istrue){
             let arr = []
             for(let a of this.valuedata){
                 arr.push({"maid":a.maid,"min_price":parseInt(a.min_price),"max_price":parseInt(a.max_price)})
             }
             
             this.post("/manor/updateMinMax", {
                   arr:arr
                }).then(res => {

                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.$emit('up_list_fun')
                    }else {
                    this.open1(res.message,'warning')
                }

             })

       }

      

   },
   pd_fun(){
        console.log(this.valuedata)
        let  length = this.valuedata.length
        for(let i=0;i<length-1;i++){  
                console.log(this.valuedata[i].max_price)
                console.log(this.valuedata[i+1].min_price)        
                if(this.valuedata[i].max_price != this.valuedata[i+1].min_price){
                    this.open1("断档了",'warning')
                    this.istrue = false
                    return false
                }else{
                    this.istrue = true
                } 
        }

   }


  }
}
</script>


<style scoped>
[v-cloak]{
    display: none;
}

.mytitle{
    height: 50px;
}
.mytitle_item{
    display: flex;
    align-items: center;
}
.mytitle_item::before{
  content:'';
  width: 5px;
  height: 15px;
  background:#409EFF;
  display: block;
  margin-right: 15px;
}
 .tb_class{
    color:#409EFF;
    font-size:30px;
    margin-top:5px;
    margin-left:15px;
  }
</style>